package org.sample.sss.service.impl;

import org.hibernate.Hibernate;
import org.sample.sss.dao.ResumeDao;
import org.sample.sss.pojo.Resume;
import org.sample.sss.service.IResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service("resumeService")
@Transactional
public class ResumeServiceImpl implements IResumeService {
    @Autowired
    private ResumeDao resumeDao;

    public List<Resume> getAllResume(){
        List<Resume> all = resumeDao.findAll();
        return all;
    }

    public Resume getOne(Long id){
        Resume resume = null;
        List<Resume> resumes = resumeDao.findById(id);
        if(resumes!=null && !resumes.isEmpty()){
            resume = resumes.get(0);
        }

        return resume;
    }

    public void deleteOne(Long id){
        resumeDao.delete(id);
    }

    public void save(Resume resume){
        resumeDao.save(resume);
    }

}

